#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QPushButton>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    this->setWindowTitle("这是一个窗口");
    QPushButton *button = new QPushButton("点击关闭窗口",this);
    button->resize(200,30);
    button->setFont(*new QFont("consolas"));
    //button->setFlat(true);
    button->setDown(true);
    button->setChecked(true);
    button->click();
    button->show();
    connect(button,&QPushButton::clicked,this,&MainWindow::autoClose);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::autoClose(){
    this->close();
}
